<!--[include file='admin_std_header.htm']-->
<script type="text/javascript" src="javascript/ajax/prototype.js"></script>
<script type="text/javascript" src="javascript/ajax/scriptaculous.js" ></script>
<script type="text/javascript" src="javascript/ajax/effects.js" ></script>
<script type="text/javascript" src="javascript/ajax/scriptaculous.js" ></script>
<script type="text/javascript" src="javascript/colorselector/colorselector.js" ></script>
<link rel="stylesheet" type="text/css" href="<!--[modulepath]-->/pnjavascript/ddtabmenu/ddtabmenufiles/ddcolortabs_blue.css" />
<script type="text/javascript">

  function getSubCategory(obj){
    var div_subcate = document.getElementById('subcategory_container');
    var category = document.getElementById('form_category_id_');
    var filter = "&filter=scy_category_id = '" + category.value + "'";
    var name = "&name=form[subcategory_id]";
    var url = "index.php?module=InnoForum&type=ajax&func=selector&ctrl=Sub_Category" + filter + name + genSession() ;
    div_subcate.innerHTML ="Loading...";
    new Ajax.Request(url, {
        method:'get',
        onSuccess: function(transport){
         var result = transport.responseText;
         div_subcate.innerHTML= result;
         }	   
      });
    
  }
  function genSession(){
    return '&r=' + Math.random(999);
  }

  var item_count = 1;
  var max_item = 5;
  function addFileItem(){
    if (item_count < max_item){
      var div = document.getElementById('fileitemcontainer');
      var file = document.createElement('input');
      var br   = document.createElement('br');
      file.setAttribute('name' , 'images[]');
      file.setAttribute('type' , 'file');
      file.setAttribute('size' , '51');
      div.appendChild(file);
      div.appendChild(br);
      item_count++;
    }else{
      var addMore = document.getElementById('addFileMore');
      addMore.innerHTML = "";
    }
    return false;
  }
  function onSubmit(){
    var buttonContainner = document.getElementById('button');
    buttonContainner.align = 'center';
    buttonContainner.innerHTML = 'Uploading please wait...<br /><img src="<!--[modulepath]-->/pnimages/loading.gif" />';
    form.submit();

    return false;
  }

  function onPreviewColor_click(containner_id){
    var containner = document.getElementById(containner_id);
    var fgcolor = document.getElementById('fgcolor').value;
    var bgcolor = document.getElementById('bgcolor').value;
    if (containner != null ){
      if ( fgcolor != '#000000'){
        containner.style.color = fgcolor;
      }
      if ( bgcolor != '#000000'){
        containner.style.backgroundColor  = bgcolor;
      }else{
        containner.style.backgroundColor  = '';
      }
    }
  }
</script>

<link rel="stylesheet" href="<!--[modulepath]-->/pnjavascript/highslide/highslide.css" type="text/css" />
<script type="text/javascript" src="<!--[modulepath]-->/pnjavascript/highslide/highslide-with-html.packed.js"></script>
<script type="text/javascript">    
    hs.graphicsDir = '<!--[modulepath]-->/pnjavascript/highslide/graphics/';
    hs.outlineType = 'rounded-white';
    hs.outlineWhileAnimating = true;
</script>

<div id="ddtabs" class="ddcolortabs">
  <ul>
    <li><a href="<!--[pnmodurl modname='InnoForum' type='admin' func='list' ctrl='Topics']-->" rel="ct1">
    <span>กลับไปรายการประกาศ</span></a></li>
  </ul>
</div>
<div class="ddcolortabsline">&nbsp;</div>

<fieldset>
<h4>เพิ่ม / แก้ไข ประกาศ</h4>
<form class='form' id='form' enctype="multipart/form-data" action="<!--[pnmodurl modname='InnoForum' type='adminform' func='submit' ctrl='Topics']-->" method="post" >
  <input type="hidden" name="form[id]" value="<!--[$_GET.id]-->" />
  <fieldset>
  <legend>รายละเอียด</legend>
  <table width="100%" border="0">
    <tr>
      <td class='td-label' >การมองเห็น </td>
      <td>
      <!--[selector_object_array_ex modname="InnoForum" 
        class="Level" 
        field="level" 
        displayField="name"  
        name="form[level]" 
        selectedValue=$form.level]-->      </td>
    </tr>
    <tr>
      <td class='td-label' >ประเภท</td>
      <td>
      <!--[selector_object_array_ex modname="InnoForum" 
        class="Type" 
        field="id" 
        displayField="name"  
        name="form[type_id]" 
        selectedValue=$form.type_id]-->      </td>
    </tr>
    <tr>
      <td class='td-label' >หมวดหมู่</td>
      <td><!--[selector_object_array_ex modname="InnoForum" 
        class="Category" 
        field="id" 
        displayField="name"  
        name="form[category_id]" 
        selectedValue=$form.category_id
        onChange="getSubCategory(this)"]--></td>
    </tr>
    <tr>
      <td class='td-label' >หมวดหมู่ย่อย </td>
      <td>
      <div id='subcategory_container'>
      <!--[assign var='category_id' value=$form.category_id]-->
      <!--[if not empty($category_id)]-->
      <!--[selector_object_array_ex modname="InnoForum" 
        class="SubCategory" 
        field="id" 
        displayField="name"  
        name="form[subcategory_id]" 
        selectedValue=$form.subcategory_id
        where="scy_category_id = '$category_id'"
        ]-->
      <!--[else]-->
        <!--[* get table prefix for query where *]-->
        <!--[pnconfiggetvar name='prefix' assign=prefix]-->
        <!--[selector_object_array_ex modname="InnoForum" 
        class="SubCategory" 
        field="id" 
        displayField="name"  
        name="form[subcategory_id]" 
        selectedValue=$form.subcategory_id
        where="scy_category_id = (SELECT MIN(cty_id) FROM `$prefix`_innoforum_category)"
        ]-->
      <!--[/if]-->
      </div>      </td>
    </tr>
    <tr>
      <td class='td-label' >หัวข้อ</td>
      <td><input name="form[title]" type="text" size="60" value="<!--[$form.title]-->" /></td>
    </tr>
    <tr>
      <td class='td-label' >สภาพสินค้า</td>
      <td><select name="form[productstate]">
        <option value="0" <!--[selected obj_value=$form.productstate cmp_value='0']--> >ของใหม่</option>
        <option value="1" <!--[selected obj_value=$form.productstate cmp_value='1']--> >ของมือสอง</option>
      </select>
      </td>
    </tr>
    <tr>
      <td class='td-label' >รถปี</td>
      <td><input name="form[car_year]" type="text" size="5" value="<!--[$form.car_year]-->" /></td>
    </tr>
    <tr>
      <td class='td-label' >สีรถ</td>
      <td><input name="form[car_color]" type="text" size="10" value="<!--[$form.car_color]-->" /></td>
    </tr>
        <tr>
      <td class='td-label' >จำนวน กม.ที่วิ่ง</td>
      <td><input name="form[car_kilometre]" type="text" size="20" value="<!--[$form.car_kilometre]-->" /></td>
    </tr>

    <tr>
      <td class='td-label' >รายละเอียด</td>
      <td><!--[spaw_editor name='form[detail]' value=$form.detail height='200px' width='100%']--></td>
    </tr>
    <tr>
      <td class='td-label' >อุปกรณ์เสริม</td>
      <td><!--[spaw_editor name='form[car_option]' value=$form.car_option height='100px' width='100%']--></td>
    </tr>
    <tr>
      <td class='td-label' >ราคา</td>
      <td><input name="form[price]" type="text" size="20" value="<!--[$form.price]-->" /> บาท</td>
    </tr>
    <tr>
      <td class='td-label' >หมดอายุ</td>
      <td><select>
        <option value="1 WEEK">1 สัปดาห์</option>
        <option value="1 MONTH">1 เดือน</option>
        <option value="3 MONTH">3 เดือน</option>
        <option value="6 MONTH" selected="selected">6 เดือน</option>
        <option value="1 YEAR">1 ปี</option>
        <option value="2 YEAR">2 ปี</option>
        <option value="5 YEAR">5 ปี</option>
        aaa
      </select>
      <br /><img src="<!--[modulepath]-->/pnimages/74.png" align='absmiddle' /> สำหรับการลบหัวข้ออัติโนมัติเมื่อถึงวันหมดอายุ</td>
    </tr>
  </table>
  </fieldset>

  <fieldset>
  <legend><a href="#" onclick="Effect.toggle('font_color', 'slide'); return false;"><img align="absmiddle" src="<!--[modulepath]-->/pnimages/001_03.gif"  />ตัวอักษรและพื้นหลัง</a></legend>
  <div id="font_color" style="display:none;" >
  <table width="100%" border="0">
    <tr>
      <td class='td-label'>สีพื้นหลัง</td>
      <td><input type="text" id="bgcolor" class='color' name="form[bgcolor]" value="<!--[$form.bgcolor]-->"></td>
    </tr>
    <tr>
      <td class='td-label'>สีตัวอักษร</td>
      <td><input type="text" id="fgcolor" class='color' name="form[fgcolor]" value="<!--[$form.fgcolor]-->"></td>
    </tr>
    <tr>
      <td class='td-label'>ตัวอย่าง</td>
      <td><div id="color_preview"><font size="6">ข้อความแสดงตัวอย่าง</font></div><button onclick="onPreviewColor_click('color_preview');return false;">แสดงตัวอย่าง</button></td>
    </tr>
  </table>
  </div>
  </fieldset>

  <fieldset>
	<legend><a href="#" onclick="Effect.toggle('contact_information', 'slide'); return false;"><img align="absmiddle" src="<!--[modulepath]-->/pnimages/001_03.gif"  />ติดต่อ</a></legend>
	<div id="contact_information">
    <table width="100%">
    <tr>
      <td width="16%" class='td-label' >ชื่อ</td>
      <td width="84%"><input name="form[name]" type="text" size="60" value="<!--[$form.name]-->" /></td>
    </tr>
    <tr>
      <td width="16%" class='td-label' >ที่อยู่</td>
      <td width="84%"><input name="form[address1]" type="text" size="60" value="<!--[$form.address1]-->" /></td>
    </tr>
    <tr>
      <td class='td-label' >อำเภอ/เขต</td>
      <td><input name="form[city]" type="text" size="40" value="<!--[$form.city]-->" /></td>
    </tr>
    <tr>
      <td class='td-label' >จังหวัด</td>
      <td><input name="form[state]" type="text" size="40" value="<!--[$form.state]-->" /></td>
    </tr>

    <tr>
      <td class='td-label' >รหัสไปรษณีย์</td>
      <td><input name="form[zip]" type="text" size="10" value="<!--[$form.zip]-->" /></td>
    </tr>
    <tr>
      <td class='td-label' >URL</td>
      <td><input name="form[url]" type="text" size="80" value="<!--[$form.url]-->" /></td>
    </tr>
    <tr>
      <td class='td-label' >Email</td>
      <td><input name="form[email]" type="text" size="40" value="<!--[$form.email]-->" /><br/>
      <input name="form[is_sendmail]" type="checkbox" value="1" checked />
      ส่งอีเมล์เมื่อมีผู้ตอบ      </td>
    </tr>
    <tr>
      <td class='td-label' >เบอร์โทรศัพท์</td>
      <td><input name="form[phone1]" type="text" size="15" value="<!--[$form.phone1]-->" /></td>
    </tr>

  </table>
  </div>
  </fieldset>

  <fieldset>
  <legend><a href="#" onclick="Effect.toggle('icon_and_model', 'slide'); return false;"><img align="absmiddle" src="<!--[modulepath]-->/pnimages/001_03.gif"  />รูป</a></legend>
  <div id="icon_and_model" >
  <table width="100%" border="0">
  <tr>
      <td class='td-label'>รูป</td>
      <td><strong>รูปแบบย่อ ปัจจุบัน</strong> <br />
        <img width="120px" src="<!--[resource type='image' path='topics' size='medium' referer_id=$_GET.id random=true]-->" />
        <table width="50%" border="0">
          <tr>
            <td width="66%"><strong>รายการ</strong> </td>
            <td width="19%"><strong>ตั้งเป็นรูปแรก</strong></td>
            <td width="15%"><strong>ลบ</strong></td>
          </tr>
          <!--[foreach from=$extendResult.images item=image]-->
          <tr>
            <td><img width="80" src="<!--[resource type='image' path='topics' size='medium' id=$image.id random=true]-->"></td>
            <td><input type="radio" name="form[image_thumb]" value="<!--[$image.id]-->"/></td>
            <td><input type="checkbox" name="form[image_delete][]" value="<!--[$image.id]-->" /></td>
          </tr>
          <!--[/foreach]-->
        </table>
      </td>
    </tr>
    <tr>
      <td>&nbsp;</td>
      <td><div id="fileitemcontainer" >
        <input name="images[]" type="file" size="51"/><br />
        <input name="images[]" type="file" size="51"/><br />
        <input name="images[]" type="file" size="51"/><br />
    <!--[if $mode eq 'new']-->
        <input name="images[]" type="file" size="51"/><br />
        <input name="images[]" type="file" size="51"/><br />
		<!--[/if]-->
      </div>
      <div id="addFileMore">
      <a href="#" onclick="addFileItem();return false;">[ เพิ่มรูป]</a>      </div></td>
    </tr>
  </table>
  </div>
  </fieldset>
 
  <fieldset>
    <div align="center" id='button'>
      <input id="button_submit" name="button_submit" value='บันทึก' type="submit"  >&nbsp;&nbsp;
      <input id="button_cancel" name="button_cancel" value='ยกเลิก' type="submit">
    </div>
  </fieldset>
</form>
</fieldset>
